<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  
</body>
<script>

  // 字符转布尔：非空字符为true，空字符为false
  // console.log( Boolean( "hello" ) );
  // console.log( Boolean( "{}" ) );
  // console.log( Boolean( "function(){}" ) );
  // console.log( Boolean( "true" ) );
  // console.log( Boolean( "false" ) );
  // console.log( Boolean( "0" ) );
  // console.log( Boolean( "1" ) );
  // console.log( Boolean( "undefined" ) );
  // console.log( Boolean( " " ) );
  // console.log( Boolean( "" ) );

  // 数值转布尔：非0和NaN为true，0和NaN为false
  // console.log( Boolean( NaN ) );
  // console.log( Boolean( 0 ) );
  // console.log( Boolean( 1 ) );
  // console.log( Boolean( 2 ) );
  // console.log( Boolean( -1 ) );
  // console.log( Boolean( -2 ) );
  // console.log( Boolean( 3.15 ) );
  // console.log( Boolean( -3.15 ) );

  // 复杂数据，对象，数组，函数：都是true
  // console.log( Boolean( {} ) );
  // console.log( Boolean( {name:"admin"} ) );
  // console.log( Boolean( [] ) );
  // console.log( Boolean( [false] ) );
  // console.log( Boolean( [0] ) );
  // console.log( Boolean( [""] ) );
  // console.log( Boolean( function(){} ) );

  // undefined和null都为false
  // console.log( Boolean( undefined ) );
  // console.log( Boolean( null ) );

</script>
</html>